/*
 * Copyright (c) 2025 Industrial Software Feature Database
 */
package com.comac.ins.isfd.rpc.xuelang;

import org.springframework.http.HttpRequest;
import org.springframework.http.client.ClientHttpRequestExecution;
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
public class XueLangOauthInterceptor implements ClientHttpRequestInterceptor {

    /**
     * 雪浪团队的接口没有权限认证，暂时输入mock值
     */
    private String getOAuthToken() {
        return "xue_lang_oauth_token";
    }

    @Override
    public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException {
        request.getHeaders().set("Authorization", "Bearer " + getOAuthToken());
        return execution.execute(request, body);
    }
}
